package org.zfes.snowier.zbss.xzy.router.complaint;
import java.util.Map;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.zfes.snowier.auth.shiro.util.SecurityUtil;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.zbss.xzy.biz.complaint.service.IComplaintReplayService;
import org.zfes.snowier.zbss.xzy.biz.complaint.service.IComplaintService;
import org.zfes.snowier.zbss.xzy.biz.dto.ComplaintDto;
@Controller("org.zfes.snowier.zbss.xzy.router.complaint.ComplaintController")
@RequestMapping("/manger/complaint")
public class ComplaintController implements BaseController {

	
	@Autowired
	private IComplaintService complaintService;
	@Autowired
	private IComplaintReplayService complaintReplayService;
	
    @RequestMapping(value="/loadComplaintDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadComplaintDataSet(@RequestBody Map<String,Object> params){
	    DataSet dataSet=  complaintService.loadComplaintDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
    @RequestMapping(value="/loadComplaint/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadComplaint(@PathVariable("id")Long id){
		Optional<ComplaintDto> ops = complaintService.loadComplaintById(id);
		return ajaxQuery("complaint",ops);
    }
	
	
    @RequestMapping(value="/setComplaintStatus/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object setComplaintStatus(@PathVariable("id")Long id,Byte status){
		complaintService.setComplaintStatus(id, status);
		return ajaxDoneSuccess("数据操作成功 ");
    }

    
    @RequestMapping(value="/replayComplaint/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object replayComplaint(@PathVariable("id")Long id,String content){
    	complaintReplayService.replayComplaint(SecurityUtil.getUserId(),SecurityUtil.getAccount(),id, content);
		return ajaxDoneSuccess("数据操作成功 ");
    }
    
}